<?php
include("./include/config.inc.php");

$i = 0;
$editorArray = "";
$select = "SELECT editor
             FROM contain
            WHERE menuId = 2";
$selectRes = mysql_query($select);
while($Row = mysql_fetch_array($selectRes))
{
  $editorArray[$i]['editor']   = $Row['editor'];
  $i++;
}

$menuArray = array();
$k = 0;
$selectMenu = "SELECT sliderId,menuId,sliderImg
                 FROM slider
                WHERE menuId = 2";
$selectMenuRes = mysql_query($selectMenu);
while($menuRow = mysql_fetch_array($selectMenuRes))
{
  $menuArray[$k]['sliderId']   = $menuRow['sliderId'];
  $menuArray[$k]['sliderImg'] = $menuRow['sliderImg'];
  $k++;
}

if(isset($_REQUEST['insertBtn']))
{
  $name = $_REQUEST['name'] && ($_REQUEST['name'] != "") ? $_REQUEST['name'] : 0 ;
  $email = $_REQUEST['email'] && ($_REQUEST['email'] != "") ? $_REQUEST['email'] : 0 ;
  $comment = $_REQUEST['comment'] && ($_REQUEST['comment'] != "") ? $_REQUEST['comment'] : 0 ;
  
  $insertComment = "INSERT INTO comment(name, email, comment)
                         VALUES('".$name."',
                                '".$email."',
                                '".$comment."')";
  $resultComment = mysql_query($insertComment);
}

$commentArray = array();
$x = 0;
$commentQuery = "SELECT commentId, name, email, comment
                   FROM comment";
$commentQueryRes = mysql_query($commentQuery);
while($rowComment = mysql_fetch_array($commentQueryRes))
{
  $commentArray[$x]['commentId'] = $rowComment['commentId'];
  $commentArray[$x]['name']      = $rowComment['name'];
  $commentArray[$x]['email']     = $rowComment['email'];
  $commentArray[$x]['comment']   = $rowComment['comment'];
  $x++;
}

include("./bottom.php");
$smarty->assign("commentArray",$commentArray);
$smarty->assign("editorArray",$editorArray);
$smarty->assign("menuArray",$menuArray);
$smarty->display("Comments.tpl");
?>